import java.util.Scanner;

/**
 * 5. 年份计数
 * https://www.lanqiao.cn/problems/1578/learning/?page=1&first_category_id=1&second_category_id=3&tag_relation=intersection&tags=%E7%9C%81%E8%B5%9B,2021&sort=pass_rate&asc=0
 */
public class Main9 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int count = 0;
        for(int year = 1000;year <= 9999;year++) {
            char[] ch = String.valueOf(year).toCharArray();
            if(ch[0] == ch[2] && ch[3] - ch[1] == 1) {
                count++;
            }
        }
        System.out.println(count);
        scan.close();
    }
}
